package book.discount
import io.github.talelin.latticy.model.ChargeDataItemDO
import java.math.BigDecimal

global io.github.talelin.latticy.service.impl.AccuracyServiceImpl accuracyService
global io.github.talelin.latticy.model.FeeDetailDO fee //定义一个JavaBean类型的全局变量
global java.math.BigDecimal ruleCost //定义一个包装类型的全局变量

rule "ruleName"
when
$chargeDataItem:ChargeDataItemDO(cdt)
then
fee.setBaseCost(new BigDecimal(${(baseCost)}));
<#list chargeAbsoluteList as absolute>
    ruleCost=ruleCost.add(accuracyService.thresholdLimit($chargeDataItem.get${absolute.ftlKey}(),${(absolute.ruleValueId)},new BigDecimal(${(absolute.min)}),new BigDecimal(${(absolute.max)}),${(absolute.accuracy)}));
</#list>
fee.setRuleCost(ruleCost);
end
